//
//  APIInfoOverview.m
//  cocoapodText
//
//  Created by apple on 16/9/20.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "NetTool.h"
#import "AFNetworking.h"
#import "APIInfoOverview.h"

//市基本信息
//本年节能效果
//当前用能情况
//地图数据
//用能分享分析（扇形）
//用能定额完成率

@interface APIInfoOverview()

@end
@implementation APIInfoOverview

- (void)fsgy_api_info_overview_withFlag:(NSString *)flag requestCode:(NSString *)code{
    AFHTTPSessionManager *session = [AFHTTPSessionManager manager];
    //申明返回的结果是json类型
    session.responseSerializer = [AFJSONResponseSerializer serializer];
    //如果报接受类型不一致请替换一致text/html或别的
    session.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/plain"];
    NSString *neturl=[NetTool fsgy_info_overview];
    NSDictionary *params=@{@"action":@"getXxgl",@"esCode":flag};
    [session GET:neturl parameters:params success:^(NSURLSessionDataTask *task, id responseObject) {
        
        if([_delegate respondsToSelector:@selector(onInfoOverview:result:flag:Orgid:requestCode:)]){
            [_delegate onInfoOverview:self result:responseObject flag:flag Orgid:@"" requestCode:code];
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        [CommonTool isSessionExpired:task];
        NSLog(@"fsgy_api_info_overview_withFlag");
    }];
}

- (void)fsgy_api_info_overview_withFlag:(NSString *)flag Orgid:(NSString *)orgid requestCode:(NSString *)code{
    AFHTTPSessionManager *session = [AFHTTPSessionManager manager];
    //申明返回的结果是json类型
    session.responseSerializer = [AFJSONResponseSerializer serializer];
    //如果报接受类型不一致请替换一致text/html或别的
    session.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/plain"];
    NSString *neturl=[NetTool fsgy_info_overview];
    NSDictionary *params=@{@"action":@"getXxgl",@"esCode":flag,@"orgid":orgid};
    [session GET:neturl parameters:params success:^(NSURLSessionDataTask *task, id responseObject) {
        if([_delegate respondsToSelector:@selector(onInfoOverview:result:flag:Orgid:requestCode:)]){
            [_delegate onInfoOverview:self result:responseObject flag:@"" Orgid:orgid requestCode:code];
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        [CommonTool isSessionExpired:task];
        NSLog(@"fsgy_api_info_overview_withFlag");
    }];
}

- (void)fsgy_api_info_overview_withOrgid:(NSString *)orgid requestCode:(NSString *)code{
    AFHTTPSessionManager *session = [AFHTTPSessionManager manager];
    //申明返回的结果是json类型
    session.responseSerializer = [AFJSONResponseSerializer serializer];
    //如果报接受类型不一致请替换一致text/html或别的
    session.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/plain"];
    NSString *neturl=[NetTool fsgy_info_overview];
    NSDictionary *params=@{@"action":@"getXxgl",@"orgid":orgid};
    [session GET:neturl parameters:params success:^(NSURLSessionDataTask *task, id responseObject) {
        if([_delegate respondsToSelector:@selector(onInfoOverview:result:flag:Orgid:requestCode:)]){
            [_delegate onInfoOverview:self result:responseObject flag:@"" Orgid:orgid requestCode:code];
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        [CommonTool isSessionExpired:task];
        NSLog(@"fsgy_api_info_overview_withOrgid");
    }];
}

- (void)fsgy_api_info_overview_withRequestCode:(NSString *)code{
    AFHTTPSessionManager *session = [AFHTTPSessionManager manager];
    //申明返回的结果是json类型
    session.responseSerializer = [AFJSONResponseSerializer serializer];
    //如果报接受类型不一致请替换一致text/html或别的
    session.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/plain"];
    NSString *neturl=[NetTool fsgy_info_overview];
    NSDictionary *params=@{@"action":@"getXxgl"};
    [session GET:neturl parameters:params success:^(NSURLSessionDataTask *task, id responseObject) {
        if([_delegate respondsToSelector:@selector(onInfoOverview:result:flag:Orgid:requestCode:)]){
            [_delegate onInfoOverview:self result:responseObject flag:@"" Orgid:@"" requestCode:code];
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        [CommonTool isSessionExpired:task];
        NSLog(@"fsgy_api_info_overview_withRequestCode");
    }];
}

@end
